package br.com.news.database.daos;

import java.util.List;

import javax.inject.Named;

import br.com.news.database.daos.interfaces.IAcessoNoticiaDao;
import br.com.news.database.entities.AcessoNoticiaEntity;
import br.com.news.database.utils.GenericDao;

@Named
public class AcessoNoticiaDao extends GenericDao<AcessoNoticiaEntity, Long> implements IAcessoNoticiaDao{

	@Override
	public List<AcessoNoticiaEntity> maisLidasDaSemana(int qntNoticias,int idCategoria) {

		return getSession().createQuery("select an from AcessoNoticiaEntity an inner join an.noticia as noticia group by noticia.idNoticia order by count(noticia.idNoticia) desc").setMaxResults(qntNoticias).list();
	}
	
}
